module.exports = function ($scope, $state, $resource, $modal, toaster, date2str, str2date) {
  $scope.myKeyup = function (e) {
		//IE 编码包含在window.event.keyCode中，Firefox或Safari 包含在event.which中
		var keycode = window.event ? e.keyCode : e.which;
		if (keycode == 13) {
			$scope.loadlist();
		}
  };
  $scope.vm = {
        'date' : '',
        'options' : {
            format: "YYYY-MM-DD",
            locale : 'zh-cn'
        }
    }
    $scope.vm1 = {
        'date' : '',
        'options' : {
            format: "YYYY-MM-DD",
            locale : 'zh-cn'
        }
    }
	/* 分页
   * ========================================= */
  $scope.maxSize = 5;            //最多显示多少个按钮
  $scope.bigCurrentPage = 1;      //当前页码
  $scope.itemsPerPage = 10; 
  $scope.searchform = {};
	//绑定列表
	$scope.loadlist = function () {
    console.log($scope.vm.date._d);
    if ($scope.vm.date._d == undefined) {
      $scope.vm.date._d = '';
    } else {
      $scope.vm.date._d = date2str($scope.vm.date._d);
    }
    if ($scope.vm1.date._d == undefined) {
      $scope.vm1.date._d = '';
    } else {
      $scope.vm1.date._d = date2str($scope.vm1.date._d);
    }
    var para = {
        pageNo:$scope.bigCurrentPage, 
        pageSize:$scope.itemsPerPage,
        start_time:($scope.vm.date._d),
        end_time:($scope.vm1.date._d)
    };
    para = angular.extend($scope.searchform, para);
		$resource('/api/as/mc/useraccount/findCompanyOrderList', {}, {}).save(para, function (res) {
			if (res.errcode === 0) {
				$scope.objs = res.data.results;
				$scope.bigTotalItems = res.data.totalRecord;
			} else {
				toaster.error({ title: '', body: res.errmsg });
			}
		});
	}

	$scope.loadlist();

};